package ua.khpi.si.kit49.diploma.core;

import java.util.ArrayList;
import java.util.List;

/**
 * Class for storing paths
 * 
 * @author netstalk3r
 * 
 */
public class Path implements Comparable<Path> {

	// list holds ids of cities
	List<Integer> path;

	public Path() {
		super();
		path = new ArrayList<Integer>();
	}

	public List<Integer> getPath() {
		return path;
	}

	public void addPoint(Integer point) {
		path.add(point);
	}

	public Integer getPoint(Integer point) {
		return path.get(point);
	}

	public int getLenght() {
		return path.size();
	}

	@Override
	public int compareTo(Path comparePath) {
		return this.getLenght() - comparePath.getLenght();
	}

	@Override
	public String toString() {
		return path.toString();
	}

	@Override
	public int hashCode() {
		int hash = 37;
		hash = hash * 27 + ((path == null) ? 0 : path.hashCode());
		return hash;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (!(obj instanceof Path))
			return false;
		Path entry = (Path) obj;
		return path.equals(entry.getPath());
	}
}
